<template>
  <div class="discounts">
    <c-title text="全部优惠"></c-title>
    <store_goods :list="list"></store_goods>
  </div>
</template>

<script>
import store_goods from "../components/store_goods.vue";
import { scrollMixin } from "utils/mixin.js";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      isLoadMore: true,
      list: [],
      page: 1,
      total_page: 0,
    };
  },
  activated() {
    this.isLoadMore = true;
    this.getData();

  },
  methods: {
    getData(page = 1) {
      $http.post('plugin.local-life.api.store.relate-goods', { id: this.$route.params.store_id, page }, '').then(res => {
        this.isLoadMore = true;
        if (res.result) {
          let data = res.data;
          this.list = page == 1 ? data.data : this.list.concat(data.data);
          this.page = data.current_page;
          this.total_page = data.last_page;
        }
      })
    },
    getMoreData() {
      this.isLoadMore = false;
      if (this.page >= this.total_page) return;
      let page = this.page + 1;
      this.getData(page);
    },
 
  },
  components: { store_goods },
};
</script>

<style scoped lang='scss'></style>